package com.aksu.wiki.util;


import java.util.UUID;
/**
 * 生成唯一主键id工具类
 */
public class UuidUtils {

    private static final int MAX_GENERATE_COUNT = 999;
    private static int generateCount = 0;
    /**
     * 生成时间戳主键
     */
    public static synchronized String getUniqueString()
    {
        if(generateCount > 999)
            generateCount = 0;
        String uniqueNumber = Long.toString(System.currentTimeMillis()) + Integer.toString(generateCount);
        generateCount++;
        return uniqueNumber;
    }
    /**
     * 生成随机 UUID 字符串
     *
     * @return 随机 UUID 字符串
     */
    public static String generateUUID() {
        return UUID.randomUUID().toString();
    }


    /**
     * 生成UUID去"-"的字符串
     * @return 总长度为32的字符串
     */
    public static String getUUIDString(){
        return UUID.randomUUID().toString().replaceAll("-", "");
    }



    public static void main(String[] args){
        for(int i=0;i<10000;i++){
            System.out.println(UuidUtils.getUniqueString());
        }
    }

}
